﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using PacMan.Components;


namespace MiniPac
{
	public enum Dir
	{
		Up,
		Right,
		Down,
		Left,
		Still
	}

	/// <summary>
	/// Resource class
	/// </summary>
	public static class R
	{
		public static readonly int Some_Kind_Of_Wall = 3; //0,1,2,3 = Wall, 4,5,6...= Air
		public static readonly int Size = 8;
		public static readonly int MarginX = 10;
		public static readonly int MarginY = 10;

		public static readonly Color blueCol = new Color(0, 10, 240, 200);
		public static readonly Color deadCol = new Color(90, 90, 90, 200);

		public static  double pVel = 0.1d * Size;

		public static double bliVel = 0.98d * pVel;
		public static double inkVel = 0.95d * pVel;
		public static double pinVel = 1.09d * pVel;
		public static double clyVel = 1.04d * pVel;


		public static int StageSizeX { get { return MazeXSize * Size + 2 * R.MarginX; } }
		public static int StageSizeY { get { return MazeYSize * Size + 2 * R.MarginY; } }

		public static SpriteFont c64_font;

		//28x32
		//	0 - path
		//	1 - wall
		//	3 - nest door
		public static byte[,] MazeArray = {
		  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
		  {1,6,6,6,6,6,6,6,6,6,6,6,6,1,1,6,6,6,6,6,6,6,6,6,6,6,6,1},
		  {1,6,1,1,1,1,6,1,1,1,1,1,6,1,1,6,1,1,1,1,1,6,1,1,1,1,6,1},
		  {1,9,1,1,1,1,6,1,1,1,1,1,6,1,1,6,1,1,1,1,1,6,1,1,1,1,9,1},
		  {1,6,1,1,1,1,6,1,1,1,1,1,6,1,1,6,1,1,1,1,1,6,1,1,1,1,6,1},
		  {1,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6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,1,6,1,1,1,1,6,1},
		  {1,9,6,6,1,1,6,6,6,6,6,6,6,5,5,6,6,6,6,6,6,6,1,1,6,6,9,1},
		  {1,1,1,6,1,1,6,1,1,6,1,1,1,1,1,1,1,1,6,1,1,6,1,1,6,1,1,1},
		  {1,1,1,6,1,1,6,1,1,6,1,1,1,1,1,1,1,1,6,1,1,6,1,1,6,1,1,1},
		  {1,6,6,6,6,6,6,1,1,6,6,6,6,1,1,6,6,6,6,1,1,6,6,6,6,6,6,1},
		  {1,6,1,1,1,1,1,1,1,1,1,1,6,1,1,6,1,1,1,1,1,1,1,1,1,1,6,1},
		  {1,6,1,1,1,1,1,1,1,1,1,1,6,1,1,6,1,1,1,1,1,1,1,1,1,1,6,1},
		  {1,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,1},
		  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
		};

		public static int MazeXSize { get { return MazeArray.GetLength(1); } }
		public static int MazeYSize { get { return MazeArray.GetLength(0); } }

		public static string TilePath = "gfx\\onePixel";
		public static Texture2D Tile;

		public static string PlayerPath = "gfx\\onePixel";
		public static Texture2D Player;

		public static string GhostPath = "gfx\\onePixel";
		public static Texture2D Ghost;

		//Sounds//
		public static SoundEffectInstance sound;
		public static SoundEffect snd_eat_dot;
		public static SoundEffectInstance snd_eat_dot_istance;
		public static SoundEffect snd_eat_ghost;

		public static SoundEffect snd_start;
		public static SoundEffect snd_die;
		public static SoundEffectInstance snd_die_inst;
		
		public static SoundEffect snd_pacman_fever;
		public static SoundEffectInstance snd_theSong;



		public static void Init(ContentManager content)
		{
			//Gfx
			Tile = content.Load<Texture2D>(R.TilePath);
			Player = content.Load<Texture2D>(R.PlayerPath);
			Ghost = content.Load<Texture2D>(R.GhostPath);

			//sound
			snd_eat_dot = content.Load<SoundEffect>("sound\\eat_sound");
			snd_eat_dot_istance = snd_eat_dot.CreateInstance();
			snd_eat_dot_istance.IsLooped = false;

			snd_eat_ghost = content.Load<SoundEffect>("sound\\eat_ghost_sound");

			snd_die = content.Load<SoundEffect>("sound\\pacman_dies_sound");
			snd_die_inst = snd_die.CreateInstance();
			snd_start = content.Load<SoundEffect>("sound\\start_game");

			snd_pacman_fever = content.Load<SoundEffect>("sound\\pacman_fever_snd");
			snd_theSong = snd_pacman_fever.CreateInstance();
			snd_theSong.IsLooped = true;
			snd_theSong.Volume = .4f;


			//font
			c64_font = content.Load<SpriteFont>("gfx\\c64font");

		}

	}
}
